#include "widget.h"
#include "./ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this ->setMaximumSize(230,300);
     this ->setMinimumSize(230,300);
    this ->setWindowTitle("计算器");

     QFont f("仿宋",10);//字体对象
     ui->mainLineEdit->setFont(f);

     //按钮上放图片
     QIcon con("E:\\dev\\qt\\calculato\\aa.png");
     ui->devButton->setIcon(con);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_oneButton_clicked()
{
    expression +="1";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_twoButton_clicked()
{
    expression +="2";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_threeButton_clicked()
{
    expression +="3";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_fourButton_clicked()
{
    expression +="4";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_fiveButton_clicked()
{
    expression +="5";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_sixButton_clicked()
{
    expression +="6";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_sevenButton_clicked()
{
    expression +="7";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_eightButton_clicked()
{
    expression +="8";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_nineButton_clicked()
{
    expression +="9";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_addButton_clicked()
{
    expression +="+";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_subButton_clicked()
{
    expression +="-";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_mulButton_clicked()
{
    expression +="*";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_divButton_clicked()
{
    expression +="/";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_zeroButton_clicked()
{
    expression +="0";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_leftButton_clicked()
{
    expression +="(";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_rightButton_clicked()
{
    expression +=")";
    ui->mainLineEdit->setText(expression);
}


void Widget::on_pushButton_6_clicked()
{
    expression.clear();
    ui->mainLineEdit->clear();
}


void Widget::on_devButton_clicked()
{
    expression.chop(1);//从最后一个字符删除
     ui->mainLineEdit->setText(expression);
}

